// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System;
using System.Collections.Generic;
using SnapObjects.Commons;

namespace SnapObjects.Data
{
    /// <summary>
    ///     Denotes that a model class should divide the query result into groups of rows.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
    public class SqlGroupByAttribute : Attribute, ISqlGroupBy
    {
        /// <summary>
        ///     Initializes a new instance of the SqlGroupByAttribute class.
        /// </summary>
        /// <param name="expressions">One or more raw SQL expressions after the keyword GROUP BY.</param>
        public SqlGroupByAttribute(params string[] expressions)
        {
            this.GroupByExpressions = expressions;

            Check.NotEmpty(expressions, nameof(expressions));
        }

        /// <summary>
        ///     Gets one or more raw SQL expressions after the keyword GROUP BY.
        /// </summary>
        public IReadOnlyList<string> GroupByExpressions { get; }
    }
}
